﻿<UserControl x:Class="ScrumFactory.Login.Login"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:props="clr-namespace:ScrumFactory.Login.Properties"        
             xmlns:SF_Helpers="clr-namespace:ScrumFactory.Windows.Helpers;assembly=ScrumFactory.Windows.Helpers"
             
             mc:Ignorable="d" 
             d:DesignHeight="540" d:DesignWidth="936"
             
                          xmlns:SF_Comp="clr-namespace:ScrumFactory.Composition;assembly=ScrumFactory.Composition"                             
        
            x:Name="thisView"

           
            SnapsToDevicePixels="True"
        >
   
    <UserControl.Resources>        
        <DataTemplate x:Key="ProviderTemplate">
            <Button Style="{StaticResource CleanButton}"
                    Width="210" Height="64"
                    Command="{Binding Model.SignInCommand, ElementName=thisView}" CommandParameter="{Binding .}"
                    ToolTip="{Binding ProviderName}"
                    Margin="0,10,10,10">                
                <Border BorderThickness="3" >
                    <Border.Background>
                        <ImageBrush ImageSource="{Binding ProviderImageUrl}" TileMode="None"/>
                    </Border.Background>                    
                    <Border.Style>
                        <Style>
                            <Setter Property="Border.BorderBrush" Value="#DDDDDD"/>
                            <Style.Triggers>
                                <Trigger Property="Border.IsMouseOver" Value="True">
                                    <Setter Property="Border.BorderBrush" Value="{StaticResource LinkBrush}"/>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </Border.Style>
                </Border>                
            </Button>                
        </DataTemplate>
    </UserControl.Resources>
    
    <SF_Helpers:PanelLayout 
        ShowCurrentProjectName="False"
        Title="{x:Static props:Resources.Sign_in}"  Background="Transparent" BorderBrush="Transparent">

        <SF_Helpers:PanelLayout.Content>
            <Grid VerticalAlignment="Stretch">                
                <Image VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="800" Height="742" Source="\Images\logoBig.png" Opacity="0.1" Margin="0,0,-100,-300"/>

                    
                    <!-- SELECAO DE SERVIDOR -->
                    <StackPanel VerticalAlignment="Top" Margin="0,50,0,0">

                    
                    <TextBlock Style="{StaticResource CoverTextTitle}" Margin="0,3,0,0"
                               Text="{x:Static props:Resources.Select_a_server_to_login}" VerticalAlignment="Center"/>
                    


                    <Grid Margin="0,50,0,0">
                        <Grid.Style>
                            <Style>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding IsServerUrlVisible}" Value="True">
                                        <Setter Property="Grid.Visibility" Value="Collapsed"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Grid.Style>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>

                            <Button Style="{StaticResource OverButton}" Command="{Binding SetStandAloneServerCommand}"
                                Grid.Column="0" HorizontalAlignment="Center" Width="300">
                                <StackPanel Margin="10">
                                    <Image Source="/Images/ServerTypes/standalone.png" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="None" />
                                    <TextBlock Text="{x:Static props:Resources.Stand_alone_server}" Foreground="White" FontWeight="Bold" FontSize="{StaticResource BigFontSize}"  HorizontalAlignment="Center"/>
                                <TextBlock Text="{x:Static props:Resources.Stand_alone_server_tooltip}" TextWrapping="Wrap" Foreground="White" FontSize="{StaticResource BigFontSize}" Margin="0,10,0,0" TextAlignment="Justify"/>
                                </StackPanel>
                            </Button>


                            <Button Style="{StaticResource OverButton}" Command="{Binding SetDemoServerCommand}"
                                 Grid.Column="1"  HorizontalAlignment="Center" Width="300">
                                <StackPanel Margin="10">
                                    <Image Source="/Images/ServerTypes/public.png" VerticalAlignment="Center" HorizontalAlignment="Center"  Stretch="None" />
                                    <TextBlock Text="{x:Static props:Resources.Public_hub_server}"  Foreground="White" FontWeight="Bold" FontSize="{StaticResource BigFontSize}" HorizontalAlignment="Center"/>
                                    <TextBlock Text="{x:Static props:Resources.Public_hub_server_tooltip}" TextWrapping="Wrap"  Foreground="White" FontSize="{StaticResource BigFontSize}"  Margin="0,10,0,0" TextAlignment="Justify"/>
                                </StackPanel>
                            </Button>

                            <Button Style="{StaticResource OverButton}" Command="{Binding SetCompanyServerCommand}"
                                Grid.Column="2"  HorizontalAlignment="Center" Width="300">
                                <StackPanel  Margin="10">
                                    <Image Source="/Images/ServerTypes/company.png" VerticalAlignment="Center" HorizontalAlignment="Center"  Stretch="None" />
                                    <TextBlock Text="{x:Static props:Resources.Your_company_server}"  Foreground="White" FontWeight="Bold" FontSize="{StaticResource BigFontSize}"  HorizontalAlignment="Center"/>
                                <TextBlock Text="{x:Static props:Resources.Your_company_server_tooltip}" TextWrapping="Wrap"  Foreground="White" FontSize="{StaticResource BigFontSize}"  Margin="0,10,0,0" TextAlignment="Justify"/>
                                </StackPanel>
                            </Button>

                            

                        </Grid>

                        <!-- ENDEREÇO DO SERVIDOR -->
                        <Border CornerRadius="5" Background="{StaticResource CoverAreaBrush}" HorizontalAlignment="Stretch" Padding="10" Margin="0,20,0,0">
                            <StackPanel>
                            <TextBlock Text="{x:Static props:Resources.server_address}" Style="{StaticResource LabelTextBlock}" Foreground="White" HorizontalAlignment="Left"/>
                                <TextBox BorderBrush="{StaticResource TextBoxBackgroundBrush}" Text="{Binding ServerUrl}" HorizontalAlignment="Stretch" />
                            <Button Command="{Binding ShowProviderPanelCommand}" Content="{x:Static props:Resources.Connect}" HorizontalAlignment="Left"></Button>
                        </StackPanel>
                            <Border.Style>
                                <Style TargetType="Border">
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding IsServerUrlVisible}" Value="False">
                                            <Setter Property="Visibility" Value="Collapsed"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </Border.Style>
                        </Border>


                    <StackPanel.Style>
                        <Style>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding ShowServerSelection}" Value="False">
                                    <Setter Property="StackPanel.Visibility" Value="Collapsed" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </StackPanel.Style>
                </StackPanel>

                <!-- SELEÇÃO DE PROVEDOR -->
                <StackPanel VerticalAlignment="Top" Margin="0,50,0,0">


                    <TextBlock  >
                        <TextBlock Style="{StaticResource CoverTextTitle}" Text="{x:Static props:Resources.Select_authenticaton_to_connect_at}" />                        
                        <Image VerticalAlignment="Center" HorizontalAlignment="Center"  Stretch="Uniform" Width="22" Height="22" Margin="5,0,2,0" >
                        <Image.Style>
                            <Style>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding IsPublicServer}" Value="True">
                                        <Setter Property="Image.Source" Value="/Images/ServerTypes/public.png" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding IsStandAloneServer}" Value="True">
                                        <Setter Property="Image.Source" Value="/Images/ServerTypes/standalone.png" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding IsCompanyServer}" Value="True">
                                        <Setter Property="Image.Source" Value="/Images/ServerTypes/company.png" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Image.Style>
                    </Image>
                        <TextBlock Style="{StaticResource CoverTextTitle}" Text="{Binding ServerUrl}" Foreground="White" />                        
                    </TextBlock>
                        
                        
                    

                    <ItemsControl
                    Margin="0,10,0,0"
                        HorizontalAlignment="Left" 
                        ItemTemplate="{StaticResource ProviderTemplate}"
                        ItemsSource="{Binding AllProviders}">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapPanel  HorizontalAlignment="Left" />
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                    </ItemsControl>

                    <Button VerticalAlignment="Center" Command="{Binding ShowServerPanelCommand}" Content="{x:Static props:Resources.Change}" HorizontalAlignment="Left" Margin="0,15,0,0"></Button>


                    <StackPanel.Style>
                        <Style>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding ShowProviderSelection}" Value="False">
                                    <Setter Property="StackPanel.Visibility" Value="Collapsed" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </StackPanel.Style>

                </StackPanel>

                    

                    

                    

                
                </Grid>

         
            </SF_Helpers:PanelLayout.Content>
        </SF_Helpers:PanelLayout>
            
</UserControl>
